<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: WebAPI::REST</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">WebAPI::REST</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/webapi/rest_rb.html">
                webapi/rest.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000009">basic_auth</a>&nbsp;&nbsp;
      <a href="#M000012">get</a>&nbsp;&nbsp;
      <a href="#M000006">http</a>&nbsp;&nbsp;
      <a href="#M000007">https</a>&nbsp;&nbsp;
      <a href="#M000011">new</a>&nbsp;&nbsp;
      <a href="#M000013">post</a>&nbsp;&nbsp;
      <a href="#M000008">public</a>&nbsp;&nbsp;
      <a href="#M000010">wsse</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="Util.html">Util</a></span>
      </div>
    </div>

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="REST/BasicAuth.html" class="link">WebAPI::REST::BasicAuth</a><br />
Class <a href="REST/HTTP.html" class="link">WebAPI::REST::HTTP</a><br />
Class <a href="REST/HTTPS.html" class="link">WebAPI::REST::HTTPS</a><br />
Class <a href="REST/Public.html" class="link">WebAPI::REST::Public</a><br />
Class <a href="REST/WSSE.html" class="link">WebAPI::REST::WSSE</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">basic_auth</span><span class="method-args">(user, password)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
    <span class="ruby-comment cmt"># File webapi/rest.rb, line 76</span>
76:     <span class="ruby-keyword kw">def</span> <span class="ruby-constant">REST</span>.<span class="ruby-identifier">basic_auth</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>)
77:       <span class="ruby-constant">BasicAuth</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>)
78:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">http</span><span class="method-args">(domain, port = 80)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File webapi/rest.rb, line 33</span>
33:     <span class="ruby-keyword kw">def</span> <span class="ruby-constant">REST</span>.<span class="ruby-identifier">http</span>(<span class="ruby-identifier">domain</span>, <span class="ruby-identifier">port</span> = <span class="ruby-value">80</span>)
34:       <span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">domain</span>, <span class="ruby-identifier">port</span>)
35:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">https</span><span class="method-args">(domain, port = 443)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File webapi/rest.rb, line 51</span>
51:     <span class="ruby-keyword kw">def</span> <span class="ruby-constant">REST</span>.<span class="ruby-identifier">https</span>(<span class="ruby-identifier">domain</span>, <span class="ruby-identifier">port</span> = <span class="ruby-value">443</span>)
52:       <span class="ruby-constant">HTTPS</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">domain</span>, <span class="ruby-identifier">port</span>)
53:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(protocol, auth = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Methods
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
     <span class="ruby-comment cmt"># File webapi/rest.rb, line 109</span>
109:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">protocol</span>, <span class="ruby-identifier">auth</span> = <span class="ruby-keyword kw">nil</span>)
110:       <span class="ruby-ivar">@protocol</span> = <span class="ruby-identifier">protocol</span>
111:       <span class="ruby-ivar">@auth</span>     = <span class="ruby-identifier">auth</span> <span class="ruby-value">? </span><span class="ruby-identifier">auth</span> <span class="ruby-operator">:</span> <span class="ruby-constant">REST</span>.<span class="ruby-identifier">public</span>
112:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">public</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
    <span class="ruby-comment cmt"># File webapi/rest.rb, line 62</span>
62:     <span class="ruby-keyword kw">def</span> <span class="ruby-constant">REST</span>.<span class="ruby-identifier">public</span>()
63:       <span class="ruby-constant">Public</span>.<span class="ruby-identifier">new</span>
64:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">
          <a href="#M000010" class="method-signature">
          <span class="method-name">wsse</span><span class="method-args">(user, password)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000010-source">
<pre>
     <span class="ruby-comment cmt"># File webapi/rest.rb, line 103</span>
103:     <span class="ruby-keyword kw">def</span> <span class="ruby-constant">REST</span>.<span class="ruby-identifier">wsse</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>)
104:       <span class="ruby-constant">WSSE</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>)
105:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">get</span><span class="method-args">(path, params = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
     <span class="ruby-comment cmt"># File webapi/rest.rb, line 114</span>
114:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span> = {})
115:       <span class="ruby-identifier">params</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span> }
116:       <span class="ruby-identifier">prm</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
117:         <span class="ruby-node">&quot;#{urlencode(k.to_s)}=#{urlencode(v.to_s)}&quot;</span>
118:       <span class="ruby-keyword kw">end</span>
119:       <span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">prm</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-value str">''</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'?'</span><span class="ruby-operator">+</span><span class="ruby-identifier">prm</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'&amp;'</span>)))
120:       <span class="ruby-ivar">@auth</span>.<span class="ruby-identifier">set!</span>(<span class="ruby-identifier">req</span>)
121:       <span class="ruby-ivar">@protocol</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">req</span>)
122:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">post</span><span class="method-args">(path, params = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
     <span class="ruby-comment cmt"># File webapi/rest.rb, line 124</span>
124:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span> = {})
125:       <span class="ruby-identifier">params</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span> }
126:       <span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
127:       <span class="ruby-identifier">req</span>.<span class="ruby-identifier">set_form_data</span>(<span class="ruby-identifier">params</span>)
128:       <span class="ruby-ivar">@auth</span>.<span class="ruby-identifier">set!</span>(<span class="ruby-identifier">req</span>)
129:       <span class="ruby-ivar">@protocol</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">req</span>)
130:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>